<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="changeData">点击修改数据</button>
        <h3 v-for="item in arr">{{item}}</h3>
    </div>
    <script>
        //数据是简单数据时 直接修改会有响应式
        const vm = new Vue({
            data(){
              return{
                arr:["小王","小李","小张","张三","李四"]
              }
            },
            methods:{
                changeData(){
                    //1，直接修改不会触发响应式更新
                    // arr[0]="dazhang"
                    //2.使用数组的变更方法可以实现响应式更新
                    // this.arr.splice(0,1,"lisi")
                    // this.arr = this.arr.filter(item => item.startsWith("小"))
                    this.arr = this.arr.map(item => item + "is pag")

                }
            }
        }).$mount("#app")
    </script>
</body>

</html>